Notes

My notes about life, work and other fascinating things around me.

Shown: 0 · Page

Debugging over HTTP
26 January 2020 ·

At the end of the week, I ran into a rather silly situation: TCP/IP debugging on a 1C server stopped working. Debug mode itself was enabled, but Designer couldn’t “see” the server’s debug contexts.

The silly part is how hard it is to find the cause: the platform gives you no clear error to work with. After checking the obvious possibilities, such as the firewall and ports, all you can do is shrug.

I solved it by switching to HTTP debugging. The overall setup is more complicated, but configuring it is quite simple. Briefly, you need to:

  • Start the server agent service with the “-debug -http” flags.
  • In Designer’s debugging settings (Tools → Options → Debug), select HTTP as the debugging protocol and the cluster debug server as the debug server.

There’s a more detailed walkthrough on ITS.

Unmaintainable Code
18 January 2020 ·

I happened across an example of a 1C query that calculates the difference between two dates in years, months, and days.

The code may work, I haven’t checked, but to me it’s a good example of what not to do. The problem is that its author will forget what most of those if-then-else branches mean within a couple of months, never mind other developers who decide to use it in their projects. The first time someone needs to change it, they’ll be better off throwing it out and writing something clearer.

And this is far from the most striking example. Just look at regular expressions for validating email addresses. Makes you want to step outside for some air, doesn’t it? :-)

One Thousand and One Nights with 1C
16 January 2020 ·

The architect of our main product (who also happens to be my team lead) talks about how we implemented 1C in Dubai. He doesn’t get bogged down in technical details, so you only need a rough idea of the subject to follow along.

The video was recorded at a developer conference in Krasnodar last June, so a few things have changed since then. For example, we now have working prototypes of the application in Arabic, and our automated testing has grown so much that Miss Vanessa pretty much deserves her own spot on the team :-)

Fifty Times Faster
5 December 2019 ·

Here’s the brief: a client’s month-end closing document takes just under an hour to post. The database isn’t especially big, but an hour is still way too long. Sure, you don’t close the month very often, and you could do it at night. Still.

I dig into the code, profile it, and see that the platform spends almost all that time in a single procedure, executing a query batch. I look at the first query and think: classic, accessing data through a dot on a composite type. The DBMS must be attaching a wagonload of joins to huge document tables, and the optimizer can’t come up with a decent plan in time.

I test the theory. But SalesDocument includes only eight document types. That should be manageable: the usual rule of thumb is that the optimizer can find a decent plan with up to eight joins.

I check the document tables: they aren’t particularly big. I run the query separately from the batch. It isn’t instantaneous, reading around 350,000 records and selecting about 200,000, but it certainly doesn’t take an hour.

All right, the batch’s first query is heavy, but it’s not the problem. I look at the second and realize that we’ve just read the entire Inventory register and selected most of its records, and now we’re reading it again and joining both result sets on a pile of conditions. The register’s record table has no suitable index: only the standard recorder index, which naturally doesn’t help.

I check: this is exactly where the platform spends most of its time waiting for the DBMS.

I couldn’t find a way around reading the whole register table twice. Every alternative I tried meant changing how the data was stored, and that wasn’t an option. So I went with a compromise: in the second query, I replaced the join to the actual register record table with a join to a temporary table created in advance and indexed on the join fields.

This was a case where 1C’s general recommendation worked perfectly: posting time fell from 50 minutes to three, and after further code optimization, to one minute. Fifty times faster than where I started.

A minute for month-end closing is usually fine, so I called it a day.

What Is the Performance Management Center For?
24 November 2019 ·

You use the Performance Management Center to:

  1. Find a system bottleneck, such as slow code or a heavy query;
  2. Investigate specific locks or deadlocks.

For the first one, turn on query analysis and, say, server call analysis. The results show which parts of the system load the application server and which load the DBMS server. This is often done without a specific problem, simply to remove bottlenecks and give the system more headroom for the future.

For the second, turn on lock or deadlock analysis when you know they occur and want a report: who blocked whom, when, on which line of code, and so forth.

In both cases, monitoring runs only during peak load, for ten to fifteen minutes. That keeps the pile of raw data manageable. PMC has to chew through it before it can show you anything, and the more you collect, the longer that takes. You also avoid picking up unrelated stuff, like load from overnight maintenance jobs.

It also keeps the collection itself from slowing things down too much. PMC can collect a monster of a technological log, and your hardware will feel it. Thirty percent slower? Hold my beer. Be careful with that.

PMC’s analytical indicators are sufficient for all of the above: query analysis, lock waits, and 1C and MS SQL deadlock analysis. Operational indicators, such as the number of queries running and their total execution time, are less popular. They usually aren’t worth the time it takes to set them up, and PMC was never really designed to collect them continuously.

Finding Methods with a Parameter
18 November 2019 ·

The task: find methods in a configuration’s common modules that have a specific parameter, DecimalPlacesFor in this example.

A normal search through the configuration code produces many false positives, such as every reference to a parameter with that name inside method bodies. The platform doesn’t support regular expression searches yet, so the easy way is to export the configuration to files and run a Bash script on the common modules directory.

The bit before the pipe does the searching. The rest trims the output down to module names and the methods found in them. For example:

Console screenshot

Profit? Profit!

What Is Bablox?
20 October 2019 ·

I watched Evgeny Filippov’s webinar about Bablox. Basically, it’s another way to measure performance. Like Apdex, it relies on timing operations, but uses a different calculation.

To calculate Bablox, multiply an operation’s duration by the salary rate of the user performing it. The salary can be:

  • An average value, if you want a rough performance comparison of the same application across several companies.
  • The user’s actual salary, if you need to convince management to spend some money on making things faster.

You end up with a figure for how much money the business has lost to a slow application. That’s the big selling point: it’s a number the average CFO can get their head around. Explaining what an Apdex of 0.5 means takes some effort; explaining a loss of 300,000 rubles doesn’t.

It also takes the guesswork out of questions that come up in every implementation. Take deciding which operations matter most: which matters more, selling goods faster or receiving them into the warehouse? Once you know how much money the company loses on each operation, the answer is much easier.

Of course, it’s not a perfect model. Suppose the application is slow for warehouse workers but runs fine for accountants. Warehouse workers earn less, so their Bablox will be low. But accountants depend on what the warehouse workers enter. Until that’s done, they have nothing to work with. The company is losing money because the application is slow for warehouse workers, but Bablox won’t show it.

I doubt Bablox will knock Apdex off its perch in the IT world, but it’s an interesting idea, and it could make talking to clients a whole lot easier.

A Large 1C Implementation
15 October 2019 ·

What counts as a large 1C implementation? In Russia, the platform is used almost everywhere, even in companies that use a lot of competing software, like SAP. Of course, some implementations are small, with 1C handling purely practical tasks like generating reports. But the Corporate Technology Support Center’s work includes truly enormous projects, such as optimizing the Delovye Linii system for five thousand concurrent users.

So in Russia these days, hundreds of people working in the same infobase at once is a medium-sized implementation. A thousand or more is a large one.

The size of the database doesn’t tell you much on its own: many configurations don’t involve large numbers of concurrent users. A classic example is 1C:Document Management; a less classic one is Avibus’s Bus Terminal Management. Bus Terminal Management can collect huge amounts of data in its central database from remote nodes in its distributed network of bus terminals and stations, without having many users working simultaneously.

A Turnover Register without Turnovers
15 October 2019 ·

If you disable “Use in totals” for every dimension of a turnover register, its turnovers will no longer be calculated. In fact, the turnover table disappears from the database altogether. Try to query it in 1C, and you’ll get an error.

That can come in handy when all we do is collect data, then filter it by recorder or other fields. We only need the register’s record table. There’s no point spending server resources calculating and storing a turnover table.

An information register naturally comes to mind for this task. But its efficiency depends on how many dimensions you plan to create: every index on an information register includes all its dimensions, plus the period for periodic registers. The platform creates a base dimension index, an index for each dimension marked “Master,” and an index for each dimension, resource, or attribute you choose to index separately. And we haven’t even reached the slice tables, which use the same approach!

So if your information register isn’t thought through all that well and has quite a few dimensions, say more than two or three, keeping all those indexes up to date can get expensive. A “flat” turnover register without turnovers starts to look pretty good.

River City Girls
30 September 2019 ·

The little one and I finished River City Girls together, a recently released beat ’em up. That’s the genre where you beat up everyone you don’t like.

In the photo, I’m watching ten-year-old Lisa confidently send a crowd of Japanese bruisers flying.

Control
14 September 2019 ·

I have two complaints about this game. First, its Altered Items: their descriptions feel a bit tame next to the SCP Foundation writers’ wild ideas. There are some pleasant exceptions, but this part still feels weaker than the rest of the game’s paranormal material.

My second gripe is where they chose to play My Dark Disquet by Poets of the Fall. Damn it, that track is far too good for such an unremarkable section! I expected it during the credits or some crazy fight.

I know both complaints sound a bit silly, but that really is all I’ve got. Control looks fantastic, plays brilliantly, and tells a great story. The only reason I won’t be giving anyone this game for New Year is that the Epic Games Store doesn’t support gifting yet :-)

Control and Poets of the Fall
23 August 2019 ·

I was already sold on the redheaded devil in the Control trailer, and now the folks at Remedy have played an unbeatable hand with this video.

Listen to this: it’s almost indecently good! Can we somehow fast-forward to the end of August? :-)

The Fermi Paradox
19 August 2019 ·

Tweet

And if the game is good, this usually happens without you noticing. There you are, playing some niche Asian horror game, and then, click! A couple of hours later you come to your senses somewhere on Wikipedia, on the page about the Second Taiwan Strait Crisis.

The article about the Fermi paradox really is good, by the way: an overview, perhaps, but a lively one written by someone who loves the subject.

Here, Have Some Duct Tape
2 August 2019 ·

My well-read friends sometimes ask what my favorite book is. And, damn it, I always feel a bit embarrassed answering, because out of all the books in the world, it’s Andy Weir’s The Martian.

Sure, it’s a great adventure novel, but there’s another reason. As a programmer, how could I not feel a bond with a guy who solved a pile of complicated engineering problems with duct tape?

Yes, of course duct tape works in a near vacuum. Duct tape works almost anywhere and everywhere. Duct tape is a gift from the gods, and we should worship it.

― Andy Weir, The Martian

Observation
28 Jule 2019 ·

It’s the near future, and you are the artificial intelligence of a space station struck by disaster. Your systems are malfunctioning, most data is lost, and the crew is God knows where. You need to work out what happened and put things right.

That’s how No Code’s recent Observation starts. The game is fantastic. If you’re into sci-fi, especially the classics, Arthur C. Clarke and that kind of thing, you’ll love it. Of the games I’ve played recently in this genre, only SOMA is better.

Do yourself a favor: skip the reviews, because journalists can’t string two words together without spoilers. Skip the official trailer too. The game has a brilliant intro, and you should see it as part of the story, not on YouTube.

The intro’s music was written by Robin Finck of Nine Inch Nails, by the way. The visuals don’t make sense when you first see them, but once you work out what you’re looking at, they really get to you.

A Good Day
9 Jule 2019 ·

Tweet

Dear diary! Today I got paid to draw Doomguy teaching Rapunzel from Disney’s Tangled how to fire a heavy assault rifle. Today was a good day!

― izra

I love artists. Special people :-)

(Also pictured: me teaching my daughter how to rush with zealots in StarCraft 2.)

Multiple Languages in Vue.js
25 June 2019 ·

I write this website in Russian, but it also has an English mirror where I gradually translate my posts. I don’t want to maintain two sets of scripts, so both domains point to the same server, which checks which domain received the request and replies in the right language.

Sounds simple, but it creates a bunch of other headaches. Getting the interface into the right language is one of them. At first, out of habit, I created two client-side arrays of phrases in different languages. I soon ditched that homegrown solution and plugged in Vue I18n.

Underneath, it’s still just two arrays of phrases that you pass in at startup. But that’s not the useful part. The plugin handles two other bits of the interface for you:

  1. Pluralization. Needed to display “page” correctly in tag statistics: in Russian, one post, two posts, and five posts require different noun forms.
  2. Date formatting, such as the date below this note.

Sure, I could have done both on the server in PHP, but that felt messy. The server should return data; the client should build the interface. No need to mix them.

Draugen
10 June 2019 ·

A fairly short story, but it makes an impression. You can’t lose, and there isn’t much choice beyond dialogue options. But the sound, the visuals, and the beautifully written characters are surprising and touching, even when you guess the plot twists before they happen.

Overall, the game reminded me of something between Firewatch and The Vanishing of Ethan Carter. I’d have liked a slightly longer story and a lot more drama, but I still loved how it ended. My feelings about the ending can be summed up by, spoiler warning, this picture :-)

And Smell Better
10 June 2019 ·

We recently released another version of FirstBIT ERP, our business automation product for the UAE. A ton of work went into it, everything works as intended, there’s plenty to be proud of, and so on. I put a lot of effort into building a full data exchange with Bitrix24, for example, and I’m very happy I managed to finish it.

But deep down I’m still a little envious of our game development colleagues: our patch notes are interesting too, of course, but you won’t find anything like this in them.

How Much?!
5 June 2019 ·

This website is written almost entirely in PHP. There’s a bit of JavaScript on the client when I need it: a redirect here, an image there, that sort of thing.

A personal website doesn’t need anything more complicated, but some time ago I felt like refreshing my web development skills. I chose Vue.js for the experiment: a popular, fast, and fairly straightforward framework.

Here’s why I’m writing all this. I installed Node.js and Vue CLI, created my first project, and nearly went gray. Three hundred megabytes of JavaScript right out of the gate?! Seriously?!