Skip to content

Restore old Evaluator switch, and put the new Evaluator behind a flag#347

Merged
stephenamar-db merged 1 commit intomasterfrom
stephenamar-db/ev
Apr 29, 2025
Merged

Restore old Evaluator switch, and put the new Evaluator behind a flag#347
stephenamar-db merged 1 commit intomasterfrom
stephenamar-db/ev

Conversation

@stephenamar-db
Copy link
Copy Markdown
Collaborator

Before:

Result "com.databricks.jsonnet.bundle.test.InternalJsonnetBuilderBenchmark.main":
  239.623 ±(99.9%) 2.487 ms/op [Average]
  (min, avg, max) = (238.165, 239.623, 242.976), stdev = 1.645
  CI (99.9%): [237.136, 242.110] (assumes normal distribution)

After:

Result "com.databricks.jsonnet.bundle.test.InternalJsonnetBuilderBenchmark.main":
  224.443 ±(99.9%) 1.335 ms/op [Average]
  (min, avg, max) = (223.504, 224.443, 226.269), stdev = 0.883
  CI (99.9%): [223.108, 225.779] (assumes normal distribution)

Looks like there's still a small regression somewhere - will continue investigating
Initial 3.3.5 commit

Result "com.databricks.jsonnet.bundle.test.InternalJsonnetBuilderBenchmark.main":
  216.718 ±(99.9%) 2.125 ms/op [Average]
  (min, avg, max) = (214.841, 216.718, 218.835), stdev = 1.406
  CI (99.9%): [214.593, 218.843] (assumes normal distribution)

@stephenamar-db
Copy link
Copy Markdown
Collaborator Author

@He-Pin

@stephenamar-db stephenamar-db merged commit 4d1ce40 into master Apr 29, 2025
6 checks passed
@He-Pin
Copy link
Copy Markdown
Contributor

He-Pin commented Apr 29, 2025

@stephenamar-db seems #329 affects performance too.

I think I need to reshape it to avoid allocation.

@He-Pin
Copy link
Copy Markdown
Contributor

He-Pin commented Apr 29, 2025

// 定义一个微服务配置生成器
local generateServiceConfig(serviceParams) =
  local defaults = {
    port: 8080,
    replicas: 1,
    memoryLimit: '512Mi',
    cpuLimit: '0.5',
    environmentVars: {},
    dependencies: [],
  };

  local params = defaults + serviceParams;
  local params2 = {
                      name: params.name,
                      version: params.version,
                      replicas: params.replicas,
                      memory: params.memoryLimit,
                      cpu: params.cpuLimit,
                      port: params.port,
                      env: std.manifestJsonEx(params.environmentVars, '  '),
                      deps: std.join(',    ', ['"%s"' % dep for dep in params.dependencies]),
                    };

  |||
    // Service configuration for %(name)s
    {
      name: "%(name)s",
      version: "%(version)s",

      deployment: {
        replicas: %(replicas)d,
        resources: {
          limits: {
            memory: "%(memory)s",
            cpu: "%(cpu)s",
          },
        },
      },

      networking: {
        port: %(port)d,
        service: "%(name)s-service",
      },

      environment: %(env)s,
      unset: input.unset,

      dependencies: [
        %(deps)s
      ],
    }
  ||| % params2;

// 生成多个服务的配置
local services = {
  'user-service': {
    name: 'user-service',
    version: '1.2.0',
    port: 8081,
    replicas: 3,
    environmentVars: {
      DB_HOST: 'postgres.example.com',
      LOG_LEVEL: 'info',
    },
    dependencies: ['auth-service', 'email-service'],
  },
  'auth-service': {
    name: 'auth-service',
    version: '1.1.0',
    port: 8082,
    memoryLimit: '1Gi',
    environmentVars: {
      JWT_SECRET: 'secret-placeholder',
      TOKEN_EXPIRY: '24h',
    },
  },
};

// 生成每个服务的配置文件内容
{
  [svcName + '.jsonnet']: generateServiceConfig(services[svcName])
  for svcName in std.objectFields(services)
}

we are testing something like this:

render it 10_000_000 times;
cost time: 61926.0 ms
cost time per time: 0.0061926 ms

@He-Pin
Copy link
Copy Markdown
Contributor

He-Pin commented Apr 29, 2025

We can collect statistics about Expr and sort them by frequency?

@stephenamar-db stephenamar-db deleted the stephenamar-db/ev branch May 15, 2025 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants