Skip to content

Instantly share code, notes, and snippets.

View IvanChepurnyi's full-sized avatar
🚀
Building awesome high performance microservices

Ivan Chepurnyi IvanChepurnyi

🚀
Building awesome high performance microservices
View GitHub Profile
@IvanChepurnyi
IvanChepurnyi / config.xml
Created November 5, 2013 09:37
Disable Mage_Log module observers
<config>
<frontend>
<controller_action_predispatch>
<observers>
<log>
<type>disabled</type>
</log>
</observers>
</controller_action_predispatch>
<controller_action_postdispatch>
@IvanChepurnyi
IvanChepurnyi / config.xml
Created November 5, 2013 09:41
Disable Mage_Reports module
<config>
<frontend>
<catalog_product_compare_remove_product>
<observers>
<reports>
<type>disabled</type>
</reports>
</observers>
</catalog_product_compare_remove_product>
<customer_login>
@IvanChepurnyi
IvanChepurnyi / test.php
Created September 8, 2016 14:38
Sample counter server in ReactPHP
<?php
require 'vendor/autoload.php';
$counter = new stdClass();
$counter->counter = 100000;
$counter->requests = 0;
$app = function ($request, $response) use ($counter) {
if ($request->getPath() === '/favicon.ico') {
@IvanChepurnyi
IvanChepurnyi / Proposal.md
Last active June 26, 2020 22:22
Architectural Proposal for Magento 2 Inventory and Prices Mechanism

Problem

There are too tight relations of stock and prices to store views and websites in Magento that results in high complexity of implementation of b2b and drop shipping solutions in Magento.

The issue was very visible with the price index structure for Magento 1, and now Magento 2 stock index follows the same idea of having an index entry per website.

This strict relation to a website makes unnecessary data duplications in case if you have global stock. Although it makes over complicated multi-warehouse delivery, as you will be required to create a separate website for each warehouse, that duplicates other product data in the flat index structure and price index.

Solution

Create a separate scope entity for Price and Inventory, for using them as scope fields for respective data structures.

@IvanChepurnyi
IvanChepurnyi / JIT
Created June 27, 2020 09:55
17k r/sec
wrk -c 500 -d 1m -t 12 -R 17k -L http://localhost:8888
Running 1m test @ http://localhost:8888
12 threads and 500 connections
Thread calibration: mean lat.: 33.914ms, rate sampling interval: 25ms
Thread calibration: mean lat.: 29.841ms, rate sampling interval: 26ms
Thread calibration: mean lat.: 25.915ms, rate sampling interval: 25ms
Thread calibration: mean lat.: 36.787ms, rate sampling interval: 27ms
Thread calibration: mean lat.: 44.106ms, rate sampling interval: 29ms
Thread calibration: mean lat.: 32.432ms, rate sampling interval: 26ms
Thread calibration: mean lat.: 42.213ms, rate sampling interval: 28ms
@IvanChepurnyi
IvanChepurnyi / gist:4136339
Last active July 30, 2020 12:01
Abstract Rule Conditions Based on Properties, not attributes
/**
* Abstract rule condition based on properties
*/
abstract class EcomDev_Rule_Model_Rule_Condition_Abstract extends Mage_Rule_Model_Condition_Abstract
{
protected $_properties = null;
/**
* Should return a label of the current condition
*
@IvanChepurnyi
IvanChepurnyi / JIT results
Last active April 29, 2021 12:33
Benchmark HTTP service
wrk -c 500 -d 30s -t 12 -R 20k -L http://localhost:8888
Running 30s test @ http://localhost:8888
12 threads and 500 connections
Thread calibration: mean lat.: 456.139ms, rate sampling interval: 3485ms
Thread calibration: mean lat.: 458.787ms, rate sampling interval: 3125ms
Thread calibration: mean lat.: 294.161ms, rate sampling interval: 1654ms
Thread calibration: mean lat.: 391.126ms, rate sampling interval: 3123ms
Thread calibration: mean lat.: 325.404ms, rate sampling interval: 2699ms
Thread calibration: mean lat.: 359.069ms, rate sampling interval: 2533ms
Thread calibration: mean lat.: 72.867ms, rate sampling interval: 222ms
@IvanChepurnyi
IvanChepurnyi / Table.php
Last active July 11, 2022 10:44
Optimized options load
<?php
/**
* Optimized version of attribute source options model
*
* That allows to preload options once and reuse them instead of doing calls to db all the time
*
*/
class EcomDev_Optimization_Model_Resource_Attribute_Source_Table
extends Mage_Eav_Model_Entity_Attribute_Source_Table
@IvanChepurnyi
IvanChepurnyi / server.php
Last active October 28, 2023 15:34
Simple multi-process ReactPHP server with workers control
<?php
/**
* Copyright © EcomDev B.V. All rights reserved.
* See LICENSE.txt for license details.
*/
declare(strict_types=1);
$port = $argv[1];
$serverName = $argv[2];