Skip to main content

Add your description here

Project description

Travertine tries to solve the problem of generating price tables fast enough for our xhg2 project. This Rust runtime is not a replacement of the Python runtime because there are still types of procedures which are not implemented in Rust.

The success or failure of this version may encourage us to complete the runtime.

The problem generating price tables

The first algorithm (implemented in Python) can be summarized as follows:

  1. Compute the AVM for the whole program. The AVM can be viewed as a mapping from attributes to a list of values which indicate a possible price variation.

  2. Generate all possible demands from the AVM.

  3. Compute the price for each demand and report both the demand (so that you get the attributes and their values) and the price.

The AVM is completely computed by looking at the procedures in the program. No outside information is needed to compute it. The generated demands are always unitary; and, since they are derived from the AMV, they are completely determined by the procedures as well.

This makes the problem of generating price tables specially suitable to be tackled efficiently in Rust.

Strategies

As far as we know, the performance bottleneck is the 3rd step: computing the prices of several hundreds (some times more) demands, but for pricing programs involving a few thousand procedures.

We have two possible strategies for this problem:

  1. Keep generating the demands (and the AVM, of course) in Python; and pass them in bulk to Rust to perform the heavy computation there.

    We discuss this strategy in Generating the Demands in Python and computing prices in Rust.

  2. Compute the demands and prices in Rust. This strategy is discussed in Generating the whole stuff in Rust.

No matter the strategy we must pass the pricing program to Rust. Our first problem is to convert our Python-side Procedure program to the Rust side.

Creating a Rust-side version of the Pricing Program

The main structure of the Rust runtime is the Virtual Machine. The virtual machine is designed to be populated incrementally but it requires that procedures are added following a “dependencies-first” order.

The Python extension provides a class Program and a function create_program so that we can create the VM and populate it. Each program has a separate instance of a VM.

Generating the Demands in Python and computing prices in Rust

Rust is all about lifetimes, ownership and the like. There will be some overhead by copy data from Python to Rust unless we can simply keep references.

This was the strategy implemented (up to version 0.8.0) and it’s much faster than doing the whole thing in Python. While performing some experiments we used py-spy to take a peek at the performance bottlenecks, we observed that Python spends too much time doing __hash__. The impact of this was major.

Generating the whole stuff in Rust

Once we paid the price of translating the Python-side procedures to a Rust Program, we could simply implement the whole algorithm in Rust.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

travertine-0.42.0a3-cp312-cp312-manylinux_2_34_x86_64.whl (8.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

travertine-0.42.0a3-cp311-cp311-manylinux_2_34_x86_64.whl (8.9 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

travertine-0.42.0a3-cp310-cp310-manylinux_2_34_x86_64.whl (8.9 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

travertine-0.42.0a3-cp39-cp39-manylinux_2_34_x86_64.whl (8.9 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.34+ x86-64

travertine-0.42.0a3-cp38-cp38-manylinux_2_34_x86_64.whl (8.9 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.34+ x86-64

File details

Details for the file travertine-0.42.0a3-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for travertine-0.42.0a3-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 927537ca8ed801272b334dbc4241c690821ed869a4d4d5cf3c5e8149055daa56
MD5 28a3cb96927990bf7c4aacd184a0d135
BLAKE2b-256 13e163d370815640ba5d3d912133dd7d51b59658f6f208f5365776cd95118c14

See more details on using hashes here.

File details

Details for the file travertine-0.42.0a3-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for travertine-0.42.0a3-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 f7d498dfdcb9cfce237c1633ccce1da48927d7bde5055c6583e97dc9756a457e
MD5 f5a843098430ad257e513bd688c4cc52
BLAKE2b-256 6466fc04938e214cac52f1f8a93fe54fd2ec3ce37b5dd1bc8f5ceab96e146b88

See more details on using hashes here.

File details

Details for the file travertine-0.42.0a3-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for travertine-0.42.0a3-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 bd4e858c95b58667018ea737bc0fa97921b1473cc7044024a689a2f10d3d8420
MD5 4589b6c75968d6aa29a62e354ed132d5
BLAKE2b-256 60e96b3fc3e0d1ef99d9077c8515fe2441c5e9e52d431de0166f25a8f68bb83b

See more details on using hashes here.

File details

Details for the file travertine-0.42.0a3-cp39-cp39-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for travertine-0.42.0a3-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 7dea47b800821a23d8839fd156a6453342a8c7759970f6090ec05cc06395293b
MD5 ebeb2bb03cc11a6aa1326514a59e3024
BLAKE2b-256 dd48219004cf7f9feee1fb355d762afea79cf5f199215352c5026bd7e02a10cf

See more details on using hashes here.

File details

Details for the file travertine-0.42.0a3-cp38-cp38-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for travertine-0.42.0a3-cp38-cp38-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 947db7049fd13853b9ddc3b70e85ff72ebfb0b72138f318397805d16c2527a49
MD5 fe07d6eca20d8e4e585450c5fba0340a
BLAKE2b-256 bdecbbcc9cd85204c1d76bb6f3a58b7156176cb160cdddc5b1a67c242cf11b85

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page